Introduction

The shiny package in R allows you to create interactive web applications with R code running behind the scenes. These applications can be run within a web browser, allowing you to share your analysis or visualizations with others without requiring them to have R installed on their computer. Shiny can be a useful tool for quickly creating proof-of-concept applications, as well as for building more complex web applications.

Folders and files:

The app.R file contains both the server and the UI code for a Shiny app.

the AirBnB.RData file contains data related to AirBnB listings in Paris. Specifically, it includes a data frame called L with information such as the property type, neighborhood, number of reviews, price, and availability for each listing. This data is used in the Shiny app to create interactive visualizations and explore the AirBnB listings in Paris.

Exercise:

We were asked to explore and analyse the airbnb Paris dataset creating a shiny application and should contain:

Relationship between prices and apartment features: This component should allow the user to explore the relationship between the price of an Airbnb apartment in Paris and its features. The features that can be explored include the number of bedrooms, the number of bathrooms, the property type (e.g. apartment, house), and the room type (e.g. private room, entire home/apt).

Number of apartments per owner: This component should allow the user to explore how many apartments each owner has listed on Airbnb in Paris. This can help to identify the most active Airbnb hosts in Paris.

Renting price per city quarter (“arrondissements”): This component should allow the user to explore the average price of Airbnb apartments in each of the 20 arrondissements (districts) of Paris. This can help to identify which arrondissements are the most expensive to stay in.

Visit frequency of the different quarters according to time: This component should allow the user to explore the frequency of Airbnb bookings in each of the 20 arrondissements of Paris over time. This can help to identify the most popular arrondissements to stay in during different seasons of the year.

Approach

started with a clear understanding of the variables that will be used in the analysis: Room type <- This feature helps to understand the type of accommodation available in the listings, such as entire homes, private rooms, or shared rooms. This information is important for users who have preferences for different types of accommodations.

Property type <- This feature describes the type of property available in the listings, such as apartments, houses, or lofts. This information can help users to find the type of property they are interested in.

Location <- This feature provides information on the geographical location of the listings in Paris, which is important for users who are interested in staying in specific areas of the city or who want to explore different neighborhoods.

Price <- This feature is a key factor for users when choosing a listing. By exploring the relationship between price and other features, such as room and property types, it is possible to understand the factors that influence the price of AirBnB listings in Paris.

Neighborhood <- This feature provides information on the different neighborhoods in Paris where the listings are located. This information is important for users who are interested in specific areas of the city

Type of owner <- This feature distinguishes between hosts and superhosts, which can help users to choose a listing based on the host’s experience and reputation.

Creating an interactive website with the Shiny package

Prerequisites

install the shiny package and its dependencies: install.packages(“shinyjs”, dependencies=TRUE) devtools::install_github(“rstudio/EDAWR”)

loading the necessary packages :

library(shiny)
library(stringr)
library(shinydashboard)
## 
## Attaching package: 'shinydashboard'
## The following object is masked from 'package:graphics':
## 
##     box
library(shinycssloaders)
library(DT)
## 
## Attaching package: 'DT'
## The following objects are masked from 'package:shiny':
## 
##     dataTableOutput, renderDataTable
library(plotly)
## Loading required package: ggplot2
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(ggplot2)
library(leaflet)
library(shinyalert)
## 
## Attaching package: 'shinyalert'
## The following object is masked from 'package:shiny':
## 
##     runExample
library(forcats)
library(purrr)
library(ggmap)
## ℹ Google's Terms of Service: ]8;;https://mapsplatform.google.com<https://mapsplatform.google.com>]8;;
## ℹ Please cite ggmap if you use it! Use `citation("ggmap")` for details.
## 
## Attaching package: 'ggmap'
## The following object is masked from 'package:plotly':
## 
##     wind
library(RColorBrewer)
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2
## ──
## ✔ tibble 3.2.1     ✔ readr  2.1.3
## ✔ tidyr  1.3.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks plotly::filter(), stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(tidyr)
library(ggpubr)
library(EDAWR)
## 
## Attaching package: 'EDAWR'
## 
## The following objects are masked from 'package:tidyr':
## 
##     population, who
## 
## The following object is masked from 'package:dplyr':
## 
##     storms

Before starting with the analysis, we need to preprocess the dataset to make it ready for our purpose.

Load the dataset:

data <- load("C:/Users/selfe/Documents/DSTI/R_Coding/Final_Project23/AirBnB_Paris.Rdata")

the original dataset contains the lists L and R :

head(L)
##         id                           listing_url   scrape_id last_scraped
## 1  4867396  https://www.airbnb.com/rooms/4867396 2.01607e+13   2016-07-03
## 2  7704653  https://www.airbnb.com/rooms/7704653 2.01607e+13   2016-07-04
## 3  2725029  https://www.airbnb.com/rooms/2725029 2.01607e+13   2016-07-04
## 4  9337509  https://www.airbnb.com/rooms/9337509 2.01607e+13   2016-07-03
## 5 12928158 https://www.airbnb.com/rooms/12928158 2.01607e+13   2016-07-04
## 6  5589471  https://www.airbnb.com/rooms/5589471 2.01607e+13   2016-07-04
##                                        name
## 1       Appartement 60m2 Rue Legendre 75017
## 2       Appart au pied de l'arc de triomphe
## 3            Nice appartment in Batignolles
## 4            Charming flat near Batignolles
## 5 Spacious bedroom near the centre of Paris
## 6           Rare, Maison individuelle 200m2
##                                                                                                                                                                                                                                                  summary
## 1      Au 2ème étage d'un bel immeuble joli 2 pièces meublé comprenant: une grande pièce à vivre lumineuse, une chambre, une cuisine, salle de douche et WC séparé. Appartement très calme et lumineux. A proximité de nombreux commerces et transports.
## 2 Nous proposons cette appartement situé en plein coeur de Paris, au pied de l'arc de triomphe. Commerçants, métro, cinéma, vous trouverez à proximité tout ce qu'il faut pour passer quelques jours à Paris en amoureux, entre copains ou en famille ! 
## 3                                                                                                                            Located in the very charming Batignolles, this cozy and bright two-room appartment will perfectly suit your stay in Paris. 
## 4                                          Welcome to my apartment ! This a quiet and cosy flat with 2 room (25 sqm2) fully furnished closed to trendy Batignolles area in the heart of the 17th district. (Near Montmartre foothill / Place de Clichy).
## 5                                                                                                                                                                                            Spacious, quiet and bright room, ideal to explore and enjoy
## 6                                                         Maison individuelle, 200 m2 habitable,rénovée en 2013. Quartier résidentiel, nombreux commerces, restaurants.  Maison familiale, pouvant accueillir 5 adultes et un enfant (1 lit en hauteur).
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             space
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
## 2 L'appartement est composé de : - une grande chambre (environ 15m2) avec un lit simple et d'un matelas d'appoint - une salle de bain avec douche, lave linge/sèche linge - un autre chambre (environ 10m2) avec un lit double (lit gigogne) et une salle de bain dans la chambre (douche) - un grand salon avec une cuisine ouverte (environ 35 m2) - wc séparé Le cuisine est tout équipé : machine nespresso, cocotte-minute, mixeur, lave vaisselle... L'appartement est très lumineux puisqu'il donne sur une avenue large mais calme. Vous trouverez à proximité plein de commercants, de bar pour sortir, de restaurants, des cinémas, des musées. Vous serez au coeur de la ville !  N'hésitez pas à nous contacter pour plus d'information, de photos...
## 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
## 4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
## 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
## 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             description
## 1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     Au 2ème étage d'un bel immeuble joli 2 pièces meublé comprenant: une grande pièce à vivre lumineuse, une chambre, une cuisine, salle de douche et WC séparé. Appartement très calme et lumineux. A proximité de nombreux commerces et transports.
## 2 Nous proposons cette appartement situé en plein coeur de Paris, au pied de l'arc de triomphe. Commerçants, métro, cinéma, vous trouverez à proximité tout ce qu'il faut pour passer quelques jours à Paris en amoureux, entre copains ou en famille ! L'appartement est composé de : - une grande chambre (environ 15m2) avec un lit simple et d'un matelas d'appoint - une salle de bain avec douche, lave linge/sèche linge - un autre chambre (environ 10m2) avec un lit double (lit gigogne) et une salle de bain dans la chambre (douche) - un grand salon avec une cuisine ouverte (environ 35 m2) - wc séparé Le cuisine est tout équipé : machine nespresso, cocotte-minute, mixeur, lave vaisselle... L'appartement est très lumineux puisqu'il donne sur une avenue large mais calme. Vous trouverez à proximité plein de commercants, de bar pour sortir, de restaurants, des cinémas, des musées. Vous serez au coeur de la ville !  N'hésitez pas à nous contacter pour plus d'information, de photos...
## 3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Located in the very charming Batignolles, this cozy and bright two-room appartment will perfectly suit your stay in Paris.
## 4                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         Welcome to my apartment ! This a quiet and cosy flat with 2 room (25 sqm2) fully furnished closed to trendy Batignolles area in the heart of the 17th district. (Near Montmartre foothill / Place de Clichy).
## 5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           Spacious, quiet and bright room, ideal to explore and enjoy
## 6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Maison individuelle, 200 m2 habitable,rénovée en 2013. Quartier résidentiel, nombreux commerces, restaurants.  Maison familiale, pouvant accueillir 5 adultes et un enfant (1 lit en hauteur).
##   experiences_offered neighborhood_overview notes transit access interaction
## 1                none                                                       
## 2                none                                                       
## 3                none                                                       
## 4                none                                                       
## 5                none                                                       
## 6                none                                                       
##   house_rules
## 1            
## 2            
## 3            
## 4            
## 5            
## 6            
##                                                                                   thumbnail_url
## 1                                                                                              
## 2           https://a1.muscache.com/im/pictures/97911969/ef37b496_original.jpg?aki_policy=small
## 3                                                                                              
## 4                                                                                              
## 5 https://a2.muscache.com/im/pictures/df47511b-0e86-4dcb-9887-569489b16020.jpg?aki_policy=small
## 6                                                                                              
##                                                                                       medium_url
## 1                                                                                               
## 2           https://a1.muscache.com/im/pictures/97911969/ef37b496_original.jpg?aki_policy=medium
## 3                                                                                               
## 4                                                                                               
## 5 https://a2.muscache.com/im/pictures/df47511b-0e86-4dcb-9887-569489b16020.jpg?aki_policy=medium
## 6                                                                                               
##                                                                                     picture_url
## 1           https://a1.muscache.com/im/pictures/61090424/02c8a8bb_original.jpg?aki_policy=large
## 2           https://a1.muscache.com/im/pictures/97911969/ef37b496_original.jpg?aki_policy=large
## 3           https://a1.muscache.com/im/pictures/96821426/ea9864f1_original.jpg?aki_policy=large
## 4 https://a2.muscache.com/im/pictures/5fa65f2d-b159-4fb5-986a-bd36cb92d2bc.jpg?aki_policy=large
## 5 https://a2.muscache.com/im/pictures/df47511b-0e86-4dcb-9887-569489b16020.jpg?aki_policy=large
## 6           https://a2.muscache.com/im/pictures/69589240/79d976c4_original.jpg?aki_policy=large
##                                                                                    xl_picture_url
## 1                                                                                                
## 2           https://a1.muscache.com/im/pictures/97911969/ef37b496_original.jpg?aki_policy=x_large
## 3                                                                                                
## 4                                                                                                
## 5 https://a2.muscache.com/im/pictures/df47511b-0e86-4dcb-9887-569489b16020.jpg?aki_policy=x_large
## 6                                                                                                
##    host_id                                   host_url host_name host_since
## 1  9703910  https://www.airbnb.com/users/show/9703910  Matthieu 2013-10-29
## 2 35777602 https://www.airbnb.com/users/show/35777602    Claire 2015-06-14
## 3 13945253 https://www.airbnb.com/users/show/13945253   Vincent 2014-04-06
## 4  5107123  https://www.airbnb.com/users/show/5107123     Julie 2013-02-16
## 5 51195601 https://www.airbnb.com/users/show/51195601   Daniele 2015-12-13
## 6 28980052 https://www.airbnb.com/users/show/28980052  Philippe 2015-03-08
##                      host_location
## 1 Nantes, Pays de la Loire, France
## 2     Paris, Île-de-France, France
## 3     Paris, Île-de-France, France
## 4     Paris, Île-de-France, France
## 5            Prato, Toscana, Italy
## 6     Paris, Île-de-France, France
##                                                                 host_about
## 1                                                                         
## 2                                                                         
## 3                                                                         
## 4 Nous sommes un jeune couple vivant à Paris. Nous aimons beaucoup voyager
## 5                                                                         
## 6                                                                         
##   host_response_time host_response_rate host_acceptance_rate host_is_superhost
## 1                N/A                N/A                  N/A                 f
## 2                N/A                N/A                  N/A                 f
## 3     within an hour               100%                  N/A                 f
## 4       within a day                50%                  N/A                 f
## 5     within an hour               100%                  60%                 f
## 6                N/A                N/A                  N/A                 f
##                                                                                       host_thumbnail_url
## 1  https://a0.muscache.com/im/users/9703910/profile_pic/1383073563/original.jpg?aki_policy=profile_small
## 2 https://a1.muscache.com/im/users/35777602/profile_pic/1438688930/original.jpg?aki_policy=profile_small
## 3 https://a0.muscache.com/im/users/13945253/profile_pic/1396781528/original.jpg?aki_policy=profile_small
## 4  https://a1.muscache.com/im/users/5107123/profile_pic/1425849895/original.jpg?aki_policy=profile_small
## 5  https://a2.muscache.com/im/pictures/e984ba68-7571-46d9-99dc-735ec6e5c9d6.jpg?aki_policy=profile_small
## 6 https://a0.muscache.com/im/users/28980052/profile_pic/1425844331/original.jpg?aki_policy=profile_small
##                                                                                            host_picture_url
## 1  https://a0.muscache.com/im/users/9703910/profile_pic/1383073563/original.jpg?aki_policy=profile_x_medium
## 2 https://a1.muscache.com/im/users/35777602/profile_pic/1438688930/original.jpg?aki_policy=profile_x_medium
## 3 https://a0.muscache.com/im/users/13945253/profile_pic/1396781528/original.jpg?aki_policy=profile_x_medium
## 4  https://a1.muscache.com/im/users/5107123/profile_pic/1425849895/original.jpg?aki_policy=profile_x_medium
## 5  https://a2.muscache.com/im/pictures/e984ba68-7571-46d9-99dc-735ec6e5c9d6.jpg?aki_policy=profile_x_medium
## 6 https://a0.muscache.com/im/users/28980052/profile_pic/1425844331/original.jpg?aki_policy=profile_x_medium
##   host_neighbourhood host_listings_count host_total_listings_count
## 1        Batignolles                   1                         1
## 2     Champs-Elysées                   1                         1
## 3        Batignolles                   1                         1
## 4        Batignolles                   1                         1
## 5             Ternes                   1                         1
## 6        Batignolles                   1                         1
##                       host_verifications host_has_profile_pic
## 1          ['email', 'phone', 'reviews']                    t
## 2          ['email', 'phone', 'reviews']                    t
## 3          ['email', 'phone', 'reviews']                    t
## 4 ['email', 'phone', 'reviews', 'jumio']                    t
## 5 ['email', 'phone', 'reviews', 'jumio']                    t
## 6                     ['email', 'phone']                    t
##   host_identity_verified                                                street
## 1                      f      Rue Legendre, Paris, Île-de-France 75017, France
## 2                      f  Avenue Mac-Mahon, Paris, Île-de-France 75017, France
## 3                      f  Rue la Condamine, Paris, Île-de-France 75017, France
## 4                      t       Rue Gauthey, Paris, Île-de-France 75017, France
## 5                      t Avenue Brunetière, Paris, Île-de-France 75017, France
## 6                      f   Rue de Saussure, Paris, Île-de-France 75017, France
##    neighbourhood neighbourhood_cleansed neighbourhood_group_cleansed  city
## 1    Batignolles    Batignolles-Monceau                           NA Paris
## 2 Champs-Elysées    Batignolles-Monceau                           NA Paris
## 3    Batignolles    Batignolles-Monceau                           NA Paris
## 4    Batignolles    Batignolles-Monceau                           NA Paris
## 5         Ternes    Batignolles-Monceau                           NA Paris
## 6    Batignolles    Batignolles-Monceau                           NA Paris
##           state zipcode market smart_location country_code country latitude
## 1 Île-de-France   75017  Paris  Paris, France           FR  France 48.88880
## 2 Île-de-France   75017  Paris  Paris, France           FR  France 48.87664
## 3 Île-de-France   75017  Paris  Paris, France           FR  France 48.88384
## 4 Île-de-France   75017  Paris  Paris, France           FR  France 48.89236
## 5 Île-de-France   75017  Paris  Paris, France           FR  France 48.88942
## 6 Île-de-France   75017  Paris  Paris, France           FR  France 48.88707
##   longitude is_location_exact property_type       room_type accommodates
## 1  2.320466                 t     Apartment Entire home/apt            2
## 2  2.293724                 t     Apartment Entire home/apt            4
## 3  2.321031                 t     Apartment Entire home/apt            2
## 4  2.322338                 t     Apartment Entire home/apt            2
## 5  2.298321                 t     Apartment    Private room            2
## 6  2.312212                 t         House Entire home/apt            6
##   bathrooms bedrooms beds bed_type
## 1         1        1    1 Real Bed
## 2         2        2    3 Real Bed
## 3         1        1    1 Real Bed
## 4         1        1    1 Real Bed
## 5         1        1    1 Real Bed
## 6         3        4    4 Real Bed
##                                                                                                                                                       amenities
## 1                                                                          {TV,"Cable TV",Internet,"Wireless Internet",Kitchen,Heating,Washer,Dryer,Essentials}
## 2                                                       {"Wireless Internet",Kitchen,"Elevator in Building","Buzzer/Wireless Intercom",Washer,Dryer,Essentials}
## 3                                          {TV,Internet,"Wireless Internet",Kitchen,"Indoor Fireplace",Heating,"Family/Kid Friendly",Washer,Essentials,Shampoo}
## 4                                                                                                       {"Wireless Internet",Kitchen,Heating,Washer,Essentials}
## 5 {"Wireless Internet",Kitchen,"Smoking Allowed","Pets Allowed",Breakfast,"Elevator in Building",Heating,"Family/Kid Friendly",Washer,Dryer,Essentials,Shampoo}
## 6                          {TV,Internet,"Wireless Internet",Kitchen,Heating,"Family/Kid Friendly",Washer,Dryer,"Smoke Detector","Fire Extinguisher",Essentials}
##   square_feet   price weekly_price monthly_price security_deposit cleaning_fee
## 1          NA  $60.00      $388.00                        $200.00       $20.00
## 2          NA $200.00                                                         
## 3          NA  $80.00      $501.00     $1,503.00          $501.00             
## 4          NA  $60.00                                     $250.00             
## 5          NA  $50.00                                                         
## 6          NA $191.00                                                   $50.00
##   guests_included extra_people minimum_nights maximum_nights calendar_updated
## 1               1        $0.00              1           1125     5 months ago
## 2               1        $0.00              1           1125    11 months ago
## 3               1        $0.00              3           1125            today
## 4               0        $0.00              2           1125     8 months ago
## 5               1        $0.00              1             30      4 weeks ago
## 6               1        $0.00              3           1125     5 months ago
##   has_availability availability_30 availability_60 availability_90
## 1               NA               0               0               0
## 2               NA               0               0               0
## 3               NA               6              23              23
## 4               NA              29              59              89
## 5               NA              29              59              89
## 6               NA               0               0               0
##   availability_365 calendar_last_scraped number_of_reviews first_review
## 1                0            2016-07-03                 1   2015-05-19
## 2                0            2016-07-04                 0             
## 3              298            2016-07-04                 1   2015-10-10
## 4              364            2016-07-03                 1   2015-12-15
## 5               89            2016-07-04                 2   2016-06-17
## 6                0            2016-07-04                 0             
##   last_review review_scores_rating review_scores_accuracy
## 1  2015-05-19                  100                     10
## 2                               NA                     NA
## 3  2015-10-10                   80                     NA
## 4  2015-12-15                   80                      6
## 5  2016-06-17                  100                     10
## 6                               NA                     NA
##   review_scores_cleanliness review_scores_checkin review_scores_communication
## 1                        10                    10                          10
## 2                        NA                    NA                          NA
## 3                        NA                    NA                          NA
## 4                        10                     8                          10
## 5                        10                    10                          10
## 6                        NA                    NA                          NA
##   review_scores_location review_scores_value requires_license license
## 1                     10                  10                f        
## 2                     NA                  NA                f        
## 3                     NA                  NA                f        
## 4                      6                   8                f        
## 5                     10                  10                f        
## 6                     NA                  NA                f        
##   jurisdiction_names instant_bookable cancellation_policy
## 1              Paris                f            flexible
## 2              Paris                f            flexible
## 3              Paris                f            flexible
## 4              Paris                f            flexible
## 5              Paris                f            flexible
## 6              Paris                f            flexible
##   require_guest_profile_picture require_guest_phone_verification
## 1                             f                                f
## 2                             f                                f
## 3                             f                                f
## 4                             f                                f
## 5                             f                                f
## 6                             f                                f
##   calculated_host_listings_count reviews_per_month
## 1                              1              0.07
## 2                              1                NA
## 3                              1              0.11
## 4                              1              0.15
## 5                              1              2.00
## 6                              1                NA
head(R)
##   listing_id       date
## 1   12007141 2016-04-16
## 2   12007141 2016-04-26
## 3   12007141 2016-05-03
## 4   12007141 2016-06-15
## 5    6666099 2015-06-21
## 6    6666099 2015-07-27

The ‘L’ list contains variables (room_type, property_type, neighborhood, price, and host_is_superhost) related to the features of the AirBnB listings in Paris

the R list contains variables ( date, day_of_week, and quarter) related to the time of the year when the listings are booked.

the select clause is used to create a subset of the ‘L’ dataset with only the useful variables for the project::

new_L <- select(L, listing_id = id, host_id, host_name,        bathrooms, bedrooms, beds, bed_type, equipments= amenities, type= property_type, room= room_type, 
                              nb_of_guests= accommodates, price, guests_included, minimum_nights, 
                              maximum_nights,availability_over_one_year= availability_365, instant_bookable, 
                              cancellation_policy, city, address= street, neighbourhood=neighbourhood_cleansed, 
                              city_quarter=zipcode, latitude, longitude, security_deposit, transit, 
                              host_response_time, superhost= host_is_superhost, host_since, 
                              listing_count= calculated_host_listings_count, host_score= review_scores_rating, 
                              reviews_per_month, number_of_reviews)
head(new_L)
##   listing_id  host_id host_name bathrooms bedrooms beds bed_type
## 1    4867396  9703910  Matthieu         1        1    1 Real Bed
## 2    7704653 35777602    Claire         2        2    3 Real Bed
## 3    2725029 13945253   Vincent         1        1    1 Real Bed
## 4    9337509  5107123     Julie         1        1    1 Real Bed
## 5   12928158 51195601   Daniele         1        1    1 Real Bed
## 6    5589471 28980052  Philippe         3        4    4 Real Bed
##                                                                                                                                                      equipments
## 1                                                                          {TV,"Cable TV",Internet,"Wireless Internet",Kitchen,Heating,Washer,Dryer,Essentials}
## 2                                                       {"Wireless Internet",Kitchen,"Elevator in Building","Buzzer/Wireless Intercom",Washer,Dryer,Essentials}
## 3                                          {TV,Internet,"Wireless Internet",Kitchen,"Indoor Fireplace",Heating,"Family/Kid Friendly",Washer,Essentials,Shampoo}
## 4                                                                                                       {"Wireless Internet",Kitchen,Heating,Washer,Essentials}
## 5 {"Wireless Internet",Kitchen,"Smoking Allowed","Pets Allowed",Breakfast,"Elevator in Building",Heating,"Family/Kid Friendly",Washer,Dryer,Essentials,Shampoo}
## 6                          {TV,Internet,"Wireless Internet",Kitchen,Heating,"Family/Kid Friendly",Washer,Dryer,"Smoke Detector","Fire Extinguisher",Essentials}
##        type            room nb_of_guests   price guests_included minimum_nights
## 1 Apartment Entire home/apt            2  $60.00               1              1
## 2 Apartment Entire home/apt            4 $200.00               1              1
## 3 Apartment Entire home/apt            2  $80.00               1              3
## 4 Apartment Entire home/apt            2  $60.00               0              2
## 5 Apartment    Private room            2  $50.00               1              1
## 6     House Entire home/apt            6 $191.00               1              3
##   maximum_nights availability_over_one_year instant_bookable
## 1           1125                          0                f
## 2           1125                          0                f
## 3           1125                        298                f
## 4           1125                        364                f
## 5             30                         89                f
## 6           1125                          0                f
##   cancellation_policy  city
## 1            flexible Paris
## 2            flexible Paris
## 3            flexible Paris
## 4            flexible Paris
## 5            flexible Paris
## 6            flexible Paris
##                                                 address       neighbourhood
## 1      Rue Legendre, Paris, Île-de-France 75017, France Batignolles-Monceau
## 2  Avenue Mac-Mahon, Paris, Île-de-France 75017, France Batignolles-Monceau
## 3  Rue la Condamine, Paris, Île-de-France 75017, France Batignolles-Monceau
## 4       Rue Gauthey, Paris, Île-de-France 75017, France Batignolles-Monceau
## 5 Avenue Brunetière, Paris, Île-de-France 75017, France Batignolles-Monceau
## 6   Rue de Saussure, Paris, Île-de-France 75017, France Batignolles-Monceau
##   city_quarter latitude longitude security_deposit transit host_response_time
## 1        75017 48.88880  2.320466          $200.00                        N/A
## 2        75017 48.87664  2.293724                                         N/A
## 3        75017 48.88384  2.321031          $501.00             within an hour
## 4        75017 48.89236  2.322338          $250.00               within a day
## 5        75017 48.88942  2.298321                              within an hour
## 6        75017 48.88707  2.312212                                         N/A
##   superhost host_since listing_count host_score reviews_per_month
## 1         f 2013-10-29             1        100              0.07
## 2         f 2015-06-14             1         NA                NA
## 3         f 2014-04-06             1         80              0.11
## 4         f 2013-02-16             1         80              0.15
## 5         f 2015-12-13             1        100              2.00
## 6         f 2015-03-08             1         NA                NA
##   number_of_reviews
## 1                 1
## 2                 0
## 3                 1
## 4                 1
## 5                 2
## 6                 0

a new data frame with only the unique rows of the new_L data frame is created, based on the listing_id column, while keeping all the columns in the original data frame that have unique combinations of values in the listing_id column.:

new_L %>% distinct(listing_id, .keep_all = TRUE)`

remove the comma separator from the price column and convert the data type from factor to character, and then take a substring of the price starting from the second character to remove the $ sign at the beginning of the price:

new_L$price <- substring(gsub(",", "", as.character(new_L$price)),2)

setting the correct variable types:

Converting numeric columns:

new_L$bathrooms <- as.numeric(new_L$bathrooms)
new_L$bedrooms <- as.numeric((new_L$bedrooms))
new_L$beds <- as.numeric((new_L$beds))
new_L$price <- as.numeric((new_L$price))
new_L$guests_included <- as.numeric((new_L$guests_included))
new_L$minimum_nights <- as.numeric((new_L$minimum_nights))
new_L$maximum_nights <- as.numeric((new_L$maximum_nights))
new_L$availability_over_one_year <- as.numeric((new_L$availability_over_one_year))
new_L$security_deposit <- as.numeric((new_L$security_deposit))
new_L$listing_count <- as.numeric((new_L$listing_count))
new_L$host_score <- as.numeric((new_L$host_score))
new_L$reviews_per_month <- as.numeric((new_L$reviews_per_month))
new_L$number_of_reviews <- as.numeric((new_L$number_of_reviews))

the neighbourhood column to character:

new_L$neighbourhood <- as.character(new_L$neighbourhood)

setting the price range of interest for the analysis

new_L <- new_L %>% filter(new_L$price >= 0 & new_L$price <= 100)

Notice that there are missing values for some columns. given the size of the dataset and the fact that only a small percentage of the values are missing, filling the missing values with the mean value is a reasonable approach. (bathrooms, bedrooms, beds and prices):

x <- mean(new_L$bathrooms, na.rm = TRUE)
y <- is.na(new_L$bathrooms)
new_L$bathrooms[y] <- x
x <- mean(new_L$bedrooms, na.rm = TRUE)
y <- is.na(new_L$bedrooms)
new_L$bedrooms[y] <- x
x <- mean(new_L$beds, na.rm = TRUE)
y <- is.na(new_L$beds)
new_L$beds[y] <- x
x = mean(new_L$price,na.rm = TRUE)
y = is.na(new_L$price) 
new_L$price[y] = x

The new_L is now cleaned, let’s Print the first rows rows of our new dataset:

head(new_L)
##   listing_id  host_id host_name bathrooms bedrooms beds bed_type
## 1    4867396  9703910  Matthieu         1        1    1 Real Bed
## 2    2725029 13945253   Vincent         1        1    1 Real Bed
## 3    9337509  5107123     Julie         1        1    1 Real Bed
## 4   12928158 51195601   Daniele         1        1    1 Real Bed
## 5    2728649 13964280   Camille         1        2    2 Real Bed
## 6    9337880 15784875 Angélique         1        1    1 Real Bed
##                                                                                                                                                      equipments
## 1                                                                          {TV,"Cable TV",Internet,"Wireless Internet",Kitchen,Heating,Washer,Dryer,Essentials}
## 2                                          {TV,Internet,"Wireless Internet",Kitchen,"Indoor Fireplace",Heating,"Family/Kid Friendly",Washer,Essentials,Shampoo}
## 3                                                                                                       {"Wireless Internet",Kitchen,Heating,Washer,Essentials}
## 4 {"Wireless Internet",Kitchen,"Smoking Allowed","Pets Allowed",Breakfast,"Elevator in Building",Heating,"Family/Kid Friendly",Washer,Dryer,Essentials,Shampoo}
## 5                    {TV,"Cable TV",Internet,"Wireless Internet",Kitchen,"Elevator in Building","Buzzer/Wireless Intercom",Heating,"Smoke Detector",Essentials}
## 6                                                                              {TV,"Wireless Internet",Kitchen,"Elevator in Building",Heating,"Smoke Detector"}
##        type            room nb_of_guests price guests_included minimum_nights
## 1 Apartment Entire home/apt            2    60               1              1
## 2 Apartment Entire home/apt            2    80               1              3
## 3 Apartment Entire home/apt            2    60               0              2
## 4 Apartment    Private room            2    50               1              1
## 5 Apartment Entire home/apt            3   100               3              1
## 6 Apartment Entire home/apt            2    99               1              1
##   maximum_nights availability_over_one_year instant_bookable
## 1           1125                          0                f
## 2           1125                        298                f
## 3           1125                        364                f
## 4             30                         89                f
## 5           1125                        365                f
## 6           1125                        365                f
##   cancellation_policy  city
## 1            flexible Paris
## 2            flexible Paris
## 3            flexible Paris
## 4            flexible Paris
## 5            flexible Paris
## 6            moderate Paris
##                                                 address       neighbourhood
## 1      Rue Legendre, Paris, Île-de-France 75017, France Batignolles-Monceau
## 2  Rue la Condamine, Paris, Île-de-France 75017, France Batignolles-Monceau
## 3       Rue Gauthey, Paris, Île-de-France 75017, France Batignolles-Monceau
## 4 Avenue Brunetière, Paris, Île-de-France 75017, France Batignolles-Monceau
## 5        Rue Nollet, Paris, Île-de-France 75017, France Batignolles-Monceau
## 6      Rue Poncelet, Paris, Île-de-France 75017, France Batignolles-Monceau
##   city_quarter latitude longitude security_deposit
## 1        75017 48.88880  2.320466               94
## 2        75017 48.88384  2.321031              208
## 3        75017 48.89236  2.322338              106
## 4        75017 48.88942  2.298321                1
## 5        75017 48.88825  2.318687              129
## 6        75017 48.87845  2.296610               24
##                            transit host_response_time superhost host_since
## 1                                                 N/A         f 2013-10-29
## 2                                      within an hour         f 2014-04-06
## 3                                        within a day         f 2013-02-16
## 4                                      within an hour         f 2015-12-13
## 5 Métro Brochant (at 5 mn by walk) within a few hours         f 2014-04-06
## 6                                        within a day         f 2014-05-20
##   listing_count host_score reviews_per_month number_of_reviews
## 1             1        100              0.07                 1
## 2             1         80              0.11                 1
## 3             1         80              0.15                 1
## 4             1        100              2.00                 2
## 5             1        100              0.26                 4
## 6             1         NA              0.25                 2

And also the summary:

summary(new_L)
##    listing_id          host_id           host_name       bathrooms    
##  Min.   :    2623   Min.   :    2626   Marie  :  452   Min.   :0.000  
##  1st Qu.: 3726444   1st Qu.: 6880774   Camille:  308   1st Qu.:1.000  
##  Median : 7200886   Median :17037121   Nicolas:  293   Median :1.000  
##  Mean   : 7307280   Mean   :23500757   Julien :  279   Mean   :1.028  
##  3rd Qu.:11078883   3rd Qu.:35784754   Sophie :  279   3rd Qu.:1.000  
##  Max.   :13819560   Max.   :81397049   Pierre :  274   Max.   :8.000  
##                                        (Other):37103                  
##     bedrooms           beds                 bed_type    
##  Min.   :0.0000   Min.   : 0.000   Airbed       :   30  
##  1st Qu.:0.8419   1st Qu.: 1.000   Couch        : 1145  
##  Median :1.0000   Median : 1.000   Futon        :  421  
##  Mean   :0.8419   Mean   : 1.414   Pull-out Sofa: 4858  
##  3rd Qu.:1.0000   3rd Qu.: 2.000   Real Bed     :32534  
##  Max.   :9.0000   Max.   :16.000                        
##                                                         
##                                                                                 equipments   
##  {}                                                                                  :  413  
##  {TV,Internet,"Wireless Internet",Kitchen,Heating,Washer,Essentials}                 :   89  
##  {Internet,"Wireless Internet",Kitchen,Heating,Washer,Essentials}                    :   86  
##  {Internet,"Wireless Internet",Kitchen,Heating,Essentials}                           :   66  
##  {TV,Internet,"Wireless Internet",Kitchen,Heating,Washer,"Smoke Detector",Essentials}:   58  
##  {TV,Internet,"Wireless Internet",Kitchen,Heating,Washer}                            :   48  
##  (Other)                                                                             :38228  
##               type                    room        nb_of_guests   
##  Apartment      :37744   Entire home/apt:31774   Min.   : 1.000  
##  Bed & Breakfast:  285   Private room   : 6672   1st Qu.: 2.000  
##  House          :  276   Shared room    :  542   Median : 2.000  
##  Loft           :  274                           Mean   : 2.618  
##  Condominium    :  220                           3rd Qu.: 4.000  
##  Other          :   98                           Max.   :16.000  
##  (Other)        :   91                                           
##      price        guests_included  minimum_nights     maximum_nights     
##  Min.   :  0.00   Min.   : 0.000   Min.   :   1.000   Min.   :1.000e+00  
##  1st Qu.: 50.00   1st Qu.: 1.000   1st Qu.:   1.000   1st Qu.:6.000e+01  
##  Median : 65.00   Median : 1.000   Median :   2.000   Median :1.125e+03  
##  Mean   : 64.67   Mean   : 1.231   Mean   :   3.048   Mean   :1.138e+05  
##  3rd Qu.: 80.00   3rd Qu.: 1.000   3rd Qu.:   3.000   3rd Qu.:1.125e+03  
##  Max.   :100.00   Max.   :16.000   Max.   :1000.000   Max.   :2.147e+09  
##                                                                          
##  availability_over_one_year instant_bookable      cancellation_policy
##  Min.   :  0.0              f:33204          flexible       :15903   
##  1st Qu.: 14.0              t: 5784          moderate       :11892   
##  Median :147.0                               strict         :11193   
##  Mean   :167.2                               super_strict_30:    0   
##  3rd Qu.:332.2                               super_strict_60:    0   
##  Max.   :365.0                                                       
##                                                                      
##                        city      
##  Paris                   :37442  
##  Paris-15E-Arrondissement:   99  
##  Paris-19E-Arrondissement:   97  
##  Paris-20E-Arrondissement:   80  
##  Paris-18E-Arrondissement:   65  
##  Paris-13E-Arrondissement:   57  
##  (Other)                 : 1148  
##                                                              address     
##  Paris, Île-de-France, France                                    :  243  
##  Rue Saint-Maur, Paris, Île-de-France 75011, France              :  177  
##  Rue du Faubourg Saint-Martin, Paris, Île-de-France 75010, France:  174  
##  Boulevard Voltaire, Paris, Île-de-France 75011, France          :  171  
##  Rue Oberkampf, Paris, Île-de-France 75011, France               :  162  
##  Rue Ordener, Paris, Île-de-France 75018, France                 :  159  
##  (Other)                                                         :37902  
##  neighbourhood       city_quarter      latitude       longitude    
##  Length:38988       75018  : 5175   Min.   :48.81   Min.   :2.221  
##  Class :character   75011  : 4009   1st Qu.:48.85   1st Qu.:2.325  
##  Mode  :character   75015  : 2942   Median :48.87   Median :2.350  
##                     75010  : 2852   Mean   :48.86   Mean   :2.347  
##                     75017  : 2721   3rd Qu.:48.88   3rd Qu.:2.374  
##                     75020  : 2614   Max.   :48.91   Max.   :2.475  
##                     (Other):18675                                  
##  security_deposit
##  Min.   :  1.00  
##  1st Qu.:  1.00  
##  Median : 38.00  
##  Mean   : 71.66  
##  3rd Qu.:129.00  
##  Max.   :304.00  
##                  
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                transit     
##                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    :13948  
##  Public transportation is a bit of a maze in Paris. I recommend you to book a transfer on the app Bonjour Paris (G00gle or Apple store).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           :   13  
##  DIRECT ACCESS From Airport CDG (Charles de Gaule-Roissy)  DIRECT ACCESS From Airport  ORLY EASY & FAST ACCESS from TRAIN STATIONS METRO Station Saint Michel line 4 is 3 minutes by foot from my place RER Station  Saint Michel line B is 3 minutes by foot from my place TAXI STATION is 3 minutes by foot from my place By CAR : 2 choices of PARKING both 5 minutes by foot from my place : “Parking Saint Michel” Rue Francisque Gay n°46 and “Parking Notre Dame” Place Jean Paul II                                                                                                                                                                                                        :    8  
##  All the facilities are included ( cleaning , towels , bed linen , heating , WIFI) .                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               :    7  
##  The place is located, just a few meters from 2 subway stops : Guy Mocquet (L13) & Lamarck Caulaincourt (L12).  Travel times on subway :  The Louvre : 30 minutes  Champs Elysées: 25 minutes  The Eiffel Tower: 40 minutes  Charles de Gaulle Airport: 60 minutes                                                                                                                                                                                                                                                                                                                                                                                                                                 :    7  
##  En métro, nous sommes à côté de la station VILLIERS (sortie N°1 avenue de VILLIERS) Ligne N° 2 (Porte Dauphine - Nation) et N° 3 (Pont de Levallois - Gallieni). Ligne direct pour Gare du Nord (station La Chapelle connectée par un passage souterrain à la gare), Opéra, Sacré-Coeur, Arc de Triomphe et les Champs-Elysées. En bus, Ligne N° 30 (Gare de l'Est - Trocadéro) / Ligne N° 94 (Montparnasse - Levallois). En voiture, Boulevard Périphérique (sortir à Porte de Clichy), dans l'avenue de Clichy, tourner à droite pour la rue LEGENDRE ; au numéro 42, tourner à gauche pour la rue Claude POUILLET. Nous avons deux places de parking, il est préférable de réserver à l'avance.:    6  
##  (Other)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           :24999  
##           host_response_time superhost      host_since    listing_count   
##                    :   29     :   29   2015-07-06:   92   Min.   : 1.000  
##  a few days or more:  823    f:37671   2015-07-05:   81   1st Qu.: 1.000  
##  N/A               : 9890    t: 1288   2016-04-19:   78   Median : 1.000  
##  within a day      : 7711              2012-10-25:   77   Mean   : 1.968  
##  within a few hours: 9615              2015-06-30:   75   3rd Qu.: 1.000  
##  within an hour    :10920              2015-07-23:   69   Max.   :91.000  
##                                        (Other)   :38516                   
##    host_score     reviews_per_month number_of_reviews
##  Min.   : 20.00   Min.   : 0.010    Min.   :  0.00   
##  1st Qu.: 87.00   1st Qu.: 0.380    1st Qu.:  0.00   
##  Median : 92.00   Median : 0.950    Median :  3.00   
##  Mean   : 90.56   Mean   : 1.392    Mean   : 12.41   
##  3rd Qu.: 97.00   3rd Qu.: 1.980    3rd Qu.: 12.00   
##  Max.   :100.00   Max.   :14.290    Max.   :392.00   
##  NA's   :11170    NA's   :10434

Analysis

Relationship between prices and apartment features:

  • Price:
summary(new_L$price)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   50.00   65.00   64.67   80.00  100.00
p1<- ggplot(new_L) + 
  geom_histogram(aes(price), fill = "#971a4a", alpha = 0.85, binwidth = 15) + 
  theme_minimal(base_size = 13) + 
  xlab("Price") + 
  ylab("Frequency") + 
  ggtitle("Distribution of Price")

p2 <- ggplot(new_L, aes(price)) +
  geom_histogram(bins = 30, aes(y = ..density..), fill = "#971a4a") + 
  geom_density(alpha = 0.2, fill = "#971a4a") + 
  ggtitle("Logarithmic distribution of Price", subtitle = expression("With" ~'log'[10] ~ "transformation of x-axis")) + 
  scale_x_log10()


ggarrange(p1,
          p2,
          nrow = 1,
          ncol=2,
          labels = c("1. ", "2. "))
## Warning: The dot-dot notation (`..density..`) was deprecated in ggplot2 3.4.0.
## ℹ Please use `after_stat(density)` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning: Transformation introduced infinite values in continuous x-axis
## Transformation introduced infinite values in continuous x-axis
## Warning: Removed 2 rows containing non-finite values (`stat_bin()`).
## Warning: Removed 2 rows containing non-finite values (`stat_density()`).

In the logarithmic distribution of the variable price a better insight view of this variable can be perceived.

  • Property type:
new_L %>%distinct(type)
##               type
## 1        Apartment
## 2            House
## 3      Condominium
## 4            Other
## 5  Bed & Breakfast
## 6             Loft
## 7                 
## 8             Dorm
## 9        Townhouse
## 10            Boat
## 11            Tent
## 12           Cabin
## 13            Tipi
## 14       Camper/RV
## 15            Cave
## 16           Villa
## 17       Treehouse
## 18     Earth House
## 19          Chalet

creates a bar chart of the number of listings according to property types. :

property_type_count <- table(new_L$type)
property_types_counts <- table(new_L$type,exclude=names(property_type_count[property_type_count[] < 4000]))
others <- sum(as.vector(property_type_count[property_type_count[] < 4000]))
property_types_counts['Others'] <- others
property_types <- names(property_types_counts)
counts <- as.vector(property_types_counts)
percentages <- scales::percent(round(counts/sum(counts), 2))
property_types_percentages <- sprintf("%s (%s)", property_types, percentages)
property_types_counts_df <- data.frame(group = property_types, value = counts)
res1 <- ggplot(property_types_counts_df, aes(x="",y=value, fill=property_types_percentages)) +
  geom_bar(width = 1,stat = "identity") +
  coord_polar("y",start = 0) +
  scale_fill_brewer("Property Types",palette = "BuPu")+
  ggtitle("Listings according to property types") +
  theme(plot.title = element_text(color = "Black", size = 12, hjust = 0.5))+
  ylab("") +
  xlab("") +
  theme(axis.ticks = element_blank(), panel.grid = element_blank(), axis.text = element_blank()) +
  geom_text(aes(label = percentages), size= 4, position = position_stack(vjust = 0.5))

res1

97% of property type are apartment

produce a boxplot that shows the distribution of prices across different property types.:

ggplot(new_L) +  
  geom_boxplot(aes(x = type,y = price,fill = type)) +
  labs(x = "Property Type",y = "Price",fill = "Property Type") +  
  coord_flip()

We can see that some property types are more expensive than the average, this property types are: Villa, Townhouse, House and Camper/RV. Since in the dataset the 96% of the listings are of type apartment, less than 4% lays in those property types.

  • Room type:
new_L %>%distinct(room)
##              room
## 1 Entire home/apt
## 2    Private room
## 3     Shared room

There exists three types of rooms: Entire home/apt, Private room and Shared room.

Listing types according to the room type:

room_types_counts <- table(new_L$room)
room_types <- names(room_types_counts)
counts <- as.vector(room_types_counts)
percentages <- scales::percent(round(counts/sum(counts), 2))
room_types_percentages <- sprintf("%s (%s)", room_types, percentages)
room_types_counts_df <- data.frame(group = room_types, value = counts)

res2 <- ggplot(room_types_counts_df, aes(x = "", y = value, fill = room_types_percentages)) +
  geom_bar(width = 1, stat = "identity") +
  coord_polar("y", start = 0) +
  scale_fill_brewer("Room Types", palette = "BuPu") +
  ggtitle("Listing types according to Room types") +
  theme(plot.title = element_text(color = "black", size = 12, hjust = 0.5)) +
  ylab("") +
  xlab("") +
  labs(fill="") +
  theme(axis.ticks = element_blank(), panel.grid = element_blank(), axis.text = element_blank()) +
  geom_text(aes(label = percentages), size = 5, position = position_stack(vjust = 0.5))

res2

82% of the listings are entire apartments.

Price by room type:

ggplot(new_L)+ 
  geom_boxplot(aes(x = room,y = price, fill = room)) + 
  labs(x = "Room Type", y = "Price", fill = "Room Type")+ 
  coord_flip()

The price of shared room is lower than private room while The price of private room is lower than entire home/apt.

let’s use a bar chart to show the mean price of each room type.:

ggplot(new_L)+ 
   geom_boxplot(aes(x = room,y = price, fill = room)) + 
   labs(x = "Room Type", y = "Price", fill = "Room Type")+ 
   coord_flip()

new_L %>% 
   group_by(room) %>% 
   summarise(mean_price = mean(price, na.rm = TRUE)) %>% 
   ggplot(aes(x = reorder(room, mean_price), y = mean_price, fill = room)) +
   geom_col(fill="#971a4a") +
   coord_flip() +
   theme_minimal() +
   labs(x = "Room Type", y = "Price") +
   geom_text(aes(label = round(mean_price,digit = 2)), hjust = 1.0, color = "white", size = 4.5) +
   ggtitle("Mean Price / Room Types") + 
   xlab("Room Type") + 
   ylab("Mean Price")

mean price of shared room < mean price of private room < mean price entire room

  • 2 boxplot showing the relationship between price and cancellation policy / relationship between price and host response time:
price_cancellation_policy <- ggplot(data = new_L, 
  aes(x = cancellation_policy, y = price, color=cancellation_policy)) +
  geom_boxplot(outlier.shape = NA) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  theme(plot.title = element_text(color = "#971a4a", size = 12, face = "bold", hjust = 0.5))+
  coord_cartesian(ylim = c(0, 500))

host_data_without_null_host_response_time <- subset(new_L, host_response_time != "N/A" & host_response_time != "")

price_response_time <- ggplot(data = host_data_without_null_host_response_time, 
  aes(x = host_response_time, y = price, color = host_response_time)) + 
  geom_boxplot(outlier.shape = NA) +
  theme(axis.text.x = element_text(angle = 90, hjust = 1)) +
  theme(plot.title = element_text(color = "#971a4a", size = 12, face = "bold", hjust = 0.5)) +
  coord_cartesian(ylim = c(0, 500))

ggarrange(price_response_time,
          price_cancellation_policy,
          nrow = 1,
          ncol = 2,
          labels = c("1. ", "2. "))

We can observe no relation in the first graph between the host response time and the price but, on the second graph we can see that the cancellation policy doesn’t have an impact on the price depending on its type

  • creates a boxplot to compare the prices of listings that are instantly bookable versus those that are not:
ggplot(data = new_L, aes(x = instant_bookable, y = price, color = instant_bookable)) +
       geom_boxplot(outlier.shape = NA) +coord_cartesian(ylim = c(0, 500))

No clear dependency with this feature.

  • relationship between the availability of the listing over a year and the price:
ggplot(new_L, aes(availability_over_one_year, price)) +
  geom_point(alpha = 0.2, color = "#971a4a") +
  geom_density(stat = "identity", alpha = 0.2) +
  xlab("Availability over a year") +
  ylab("Price") +
  ggtitle("Relationship between availability and price") 

No clear dependency with this feature.

Number of apartments per owner:

  • Hosts:
count_by_host_1 <- new_L %>% 
  group_by(host_id) %>%
  summarise(number_apt_by_host = n()) %>%
  ungroup() %>%
  mutate(groups = case_when(
    number_apt_by_host == 1 ~ "001",
    between(number_apt_by_host, 2,10) ~ "002-010",
    number_apt_by_host > 10 ~ "011-153"))

count_by_host_2 <- count_by_host_1 %>%
  group_by(groups) %>%
  summarise(counting = n()) %>%
  arrange(desc(counting), .by_group = TRUE)

num_apt_by_host_id <- (ggplot(count_by_host_2, aes(x = "", y = counting)) +  
              geom_col(aes(fill = factor(groups)), color = "white") + 
              geom_text(aes(y = counting / 1.23, label = counting),color = "black",size = 4)+ 
              labs(x = "", y = "", fill = "Number of apartments per owner") + 
              coord_polar(theta = "y"))+
              theme_minimal()

superhost <- (ggplot(new_L) + 
                geom_bar(aes(x='' , fill=superhost)) +
                coord_polar(theta='y') +
                scale_fill_brewer(palette="BuPu")) +
                theme_minimal()

ggarrange(num_apt_by_host_id,
          superhost,
          nrow=2,
          ncol=1,
          align = "hv")

Most of the hosts have only one listing. There is also a minority of superhosts.

Top 20 hosts in Paris:

count_by_host_3 <- new_L %>%
  group_by(host_id) %>%
  summarise(number_apt_by_host = n()) %>%
  arrange(desc(number_apt_by_host))

top_listings_by_host <- count_by_host_3 %>%
  top_n(n=20, wt = number_apt_by_host)

knit_print.data.frame <- top_listings_by_host

knit_print.data.frame 
## # A tibble: 22 × 2
##     host_id number_apt_by_host
##       <int>              <int>
##  1  3972699                 57
##  2 67879895                 42
##  3  2503671                 39
##  4  2107478                 31
##  5 39352838                 30
##  6 24579331                 23
##  7 56016826                 22
##  8 12984381                 21
##  9 10574661                 19
## 10 11593703                 19
## # ℹ 12 more rows

Renting price per city quarter:

listings_quarter <- ggplot(new_L, aes(x = fct_infreq(neighbourhood), fill = room)) +
    geom_bar() +
    labs(title = "Nb. Listings per city quarter",
         x = "Neighbourhood", y = "Nb. of listings") +
    theme(legend.position = "bottom",axis.text.x = element_text(angle = 90, hjust = 1), 
          plot.title = element_text(color = "black", size = 12,  hjust = 0.5))

average_prices <- aggregate(cbind(new_L$price),
                  by = list(arrond = new_L$city_quarter),
                  FUN = function(x) mean(x))

price <- ggplot(data = average_prices, aes(x = arrond, y = V1)) +
    geom_bar(stat = "identity", fill = "#971a4a", width = 0.7) +
  geom_text(aes(label = round(V1, 2)), size=4) +
    coord_flip() +
    labs(title = "Average daily price per city quarter", 
         x = "City quarters", y = "Average daily price") +
    theme(legend.position = "bottom",axis.text.x = element_text(angle = 90, hjust = 1), 
          plot.title = element_text(color = "black", size = 12,  hjust = 0.5))

ggarrange(listings_quarter,
          price,
          nrow =1,
          ncol = 2,
          labels = c("1. ", "2. "))

displays a bar chart of the top 10 neighborhoods with the most listings:

new_L %>%
  group_by(neighbourhood) %>%
  dplyr::summarize(num_listings = n(), borough = unique(neighbourhood)) %>%
  top_n(n = 10, wt = num_listings) %>%
  ggplot(aes(x = fct_reorder(neighbourhood, num_listings), y = num_listings, fill = borough)) +
  geom_col() +
  coord_flip() +
  labs(title = "Top 10 neighborhoods by nb. of listings", x = "Neighbourhood", y = "Nb. of listings")

number of rented apartments over time for each neighborhood:

new_data <- inner_join(new_L, R, by = "listing_id")
new_data = mutate(new_data,year = as.numeric(str_extract(new_data$date, "^\\d{4}")))

new_data["date"] <- new_data["date"] %>% map(., as.Date)

longitudinal  <- new_data %>%
  group_by(date, neighbourhood) %>%
  summarise(count_obs = n())
## `summarise()` has grouped output by 'date'. You can override using the
## `.groups` argument.
time_location <- (ggplot(longitudinal, aes(x = date,  y = count_obs, group = 1)) +
                  geom_line(linewidth = 0.5, colour = "lightblue") +
                  stat_smooth(color = "#971a4a", method = "loess") +
                  scale_x_date(date_labels = "%Y") +
                  labs(x = "Year", y = "Nb. Rented Appartment") +
                  facet_wrap(~ neighbourhood))

time_location
## `geom_smooth()` using formula = 'y ~ x'

The most visited and rented locations in Paris are the cheapest ones.

Map representing price range within Paris neighborhoods (higher the closer we are to the center Paris):

height <- max(new_L$latitude) - min(new_L$latitude)
width <- max(new_L$longitude) - min(new_L$longitude)

paris_limits <- c(bottom = min(new_L$latitude)  - 0.1 * height, 
                top = max(new_L$latitude)  + 0.1 * height,
                left = min(new_L$longitude) - 0.1 * width,
                right = max(new_L$longitude) + 0.1 * width)

map <- get_stamenmap(paris_limits, zoom = 12)
## ℹ Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.
ggmap(map) +
  geom_point(data = new_L, mapping = aes(x = longitude, y = latitude, col = log(price))) +
  scale_color_distiller(palette = "BuPu", direction = 1)

Visit frequency of the different quartes according to time:

new_data <- inner_join(new_L, R, by = "listing_id")
new_data = mutate(new_data, year = as.numeric(str_extract(new_data$date, "^\\d{4}")))
     
res3 <- ggplot(new_data) +
  geom_bar(aes(y =city_quarter ,fill=factor(year))) +
  scale_size_area() +
  labs( x="Frequency", y="City quarter",fill="Year") +
  scale_fill_brewer(palette ="BuPu")
    
ggplotly(res3)

display geographical data

interactive map using Leaflet :

Neighborhood listings map:

df <- select(new_L, longitude, neighbourhood, latitude, price)
leaflet(df %>% select(longitude, neighbourhood, latitude, price))%>%
  setView(lng = 2.3488, lat = 48.8534, zoom = 12) %>%
   addTiles() %>% 
  addMarkers(clusterOptions = markerClusterOptions()) %>%
  addMiniMap()
## Assuming "longitude" and "latitude" are longitude and latitude, respectively

shows only listings that are marked as “superhost”:

dfsuperhost <- select(new_L, longitude, neighbourhood, latitude, price)
dfsuperhost <- filter(new_L, superhost =="t")
leaflet(dfsuperhost %>% select(longitude, neighbourhood, latitude, price))%>%
  setView(lng = 2.3488, lat = 48.8534 ,zoom = 12) %>%
   addTiles() %>% 
  addMarkers(clusterOptions = markerClusterOptions()) %>%
  addMiniMap()
## Assuming "longitude" and "latitude" are longitude and latitude, respectively

Conclusion

the analysis showed that the majority of the listings are concentrated in the central areas of Paris, with a higher concentration around popular touristic areas. The top 10 neighborhoods by the number of listings are located in the central areas of Paris. The longitudinal analysis revealed that the number of rented apartments has been increasing over time, which could be an indicator of the growth of the tourism industry in Paris.

It seems like the majority of hosts on the platform are individuals renting out their own homes or apartments, rather than commercial operators with multiple listings.`.

The dataset only includes AirBnB listings, so it may not necessarily reflect the entire rental market in Paris. However, The closer the apartment is to the center of Paris, the more expensive it is. The neighborhood in Paris with the highest number of listings is Butter-Montmartre

It is possible that people prefer to rent entire homes/apartments because they provide more privacy and comfort, especially for families or larger groups. Additionally, people may prefer this option because it allows them to have a full kitchen and other amenities, which can save them money compared to eating out every meal.

Regarding the Butter-Montmartre neighborhood, it is possible that this neighborhood is popular among tourists for its location and attractions. It is close to popular tourist destinations like the Sacré-Cœur Basilica and the Moulin Rouge, and it also has a variety of restaurants, bars, and shops. This may make it an attractive location for people visiting Paris.

Finally, there is a minority of superhosts in comparison to hosts. Becoming a superhost on Airbnb requires meeting certain criteria, such as maintaining a high overall rating, receiving a certain number of bookings, and having a low cancellation rate, among others. So it’s not surprising that only a minority of hosts achieve this status. However, being a superhost can be beneficial for hosts as it can lead to more bookings and higher income.